package com.algorithm;

public class SelectSort {
    public int[] select(int[] nums) {
        int min;
        int tmp;
        for (int i = 0; i < nums.length; i++) {
            min = i;
            for (int j = i; j < nums.length; j++) {
                if (nums[j] < nums[i]) {
                    min = j;
                }
            }
            tmp = nums[i];
            nums[i] = nums[min];
            nums[min] = tmp;
        }

        return nums;
    }

    public static void main(String[] args) {
        int[] nums = new int[] {20,40,30,10,60,50};

        int[] sorted = new SelectSort().select(nums);
        for (int i : sorted) {
            System.out.println(i);
        }
    }
}
